package dataprovider;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class DataProviderUtils {

	protected static Map<String, String> resolverDataProviderArguments(
			Method testMethod) throws Exception {

		if (testMethod == null)
			throw new IllegalArgumentException();

		DataProviderArguments args = testMethod
				.getAnnotation(DataProviderArguments.class);

		if (args == null)
			throw new IllegalArgumentException("");

		if (args.value() == null || args.value().length == 0)
			throw new IllegalArgumentException("");

		Map<String, String> arguments = new HashMap<String, String>();

		for (int i = 0; i < args.value().length; i++) {

			String[] parts = args.value()[i].split("=");
			arguments.put(parts[0], parts[1]);

		}
		return arguments;

	}
}
